import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '../views/layout/index.vue'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    redirect: "/home/dashboard"
  },
  {
    path: '/login',
    name: 'login',
    component: () => import( /* webpackChunkName: "login" */ '../views/login/index.vue')
  },
  {
    path: '/home',
    name: 'home',
    component: Layout,
    meta: {
      title: "首页",
      icon: "icon-panel",
      type: "2"
    },
    redirect: "/home/dashboard",
    children: [{
        path: "dashboard",
        name: "dashboard",
        component: () => import( /* webpackChunkName: "dashboard" */ '../views/dashboard/index.vue'),
        meta: {
          title: "仪表盘",
          type: "2"
        }
      },
      {
        path: "data",
        name: "dashboarddata",
        component: () => import( /* webpackChunkName: "dashboarddata" */ '../views/dashboard/data.vue'),
        meta: {
          title: "设备数据",
          type: "2"
        }

      }
    ]
  },
  { //设备的路由和子路由
    path: '/device',
    name: 'device',
    component: Layout,
    meta: {
      title: "设备",
      icon: "icon-luyouqi",
      type: "2"
    },

    children: [{
        path: "gateway",
        name: "gateway",
        component: () => import( /* webpackChunkName: "gateway" */ '../views/device/gateway.vue'),
        meta: {
          title: "网关",
          type: "2"
        }
      },
      {
        path: "group",
        name: "group",
        component: () => import( /* webpackChunkName: "group" */ '../views/device/group.vue'),
        meta: {
          title: "设备群组",
          type: "2"
        }
      },
      {
        path: "list",
        name: "list",
        component: () => import( /* webpackChunkName: "list" */ '../views/device/list.vue'),
        meta: {
          title: "传感器列表",
          type: "2"
        }
      }
    ]
  },
  { //计费的路由和子路由
    path: "/bill",
    name: 'bill',
    component: Layout,
    meta: {
      title: "计费",
      icon: "icon-fyxx",
      type: "2"
    },
    children: [{
        path: "account_info",
        name: "accountInfo",
        component: () => import( /* webpackChunkName:"accountInfo" */ '../views/bill/account_info.vue'),
        meta: {
          title: "账户信息",
          type: "2"
        }
      },
      {
        path: "recharge_record",
        name: "rechargeRecord",
        component: () => import( /* webpackChunkName:"rechargeRecord" */ '../views/bill/recharge_record.vue'),
        meta: {
          title: "充值记录",
          type: "2"
        }
      },
      {
        path: "use_record",
        name: "useRecord",
        component: () => import( /* webpackChunkName:"useRecord" */ '../views/bill/use_record.vue'),
        meta: {
          title: "使用记录",
          type: "2"
        }
      },
    ]
  },
  { //账号的子路由
    path: "/account",
    name: 'account',
    component: Layout,
    meta: {
      title: "账号",
      icon: "icon-account",
      type: "1"
    },
    children: [{
        path: "account_list",
        name: "account_list",
        component: () => import( /* webpackChunkName:"account_list" */ '../views/account/account_list.vue'),
        meta: {
          title: "账号列表",
          type: "1"
        }
      },
      {
        path: "add_account",
        name: "add_account",
        component: () => import( /* webpackChunkName:"rechargeRecord" */ '../views/account/add_account.vue'),
        meta: {
          title: "添加账号",
          type: "1"
        }
      }
    ]
  },
  {
    path: '*',
    name: 'page404',
    component: () => import( /* webpackChunkName: "page404" */ '../views/page404/index.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router